package com.spring.camel.project;

import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
/**
  * @Date 2020/4/22 0:08
  * @Author wsh
  * @Desc 从activemq请求数据到本地
  */
public class ActiveMQToConsumer {
    public static void main(String[] args) throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("activemq:queue:my_que")
                        .to("seda:end");
            }
        });
        context.start();
        ConsumerTemplate template = context.createConsumerTemplate();
        Object bj = template.receiveBody("seda:end", Object.class);
        System.out.println("获取的消息"+bj.toString());
    }
}
